package com.funtester.seven.day3;

import java.util.*;

public class RandomT {

    public static void main(String[] args) {
        Random random = new Random();
//        int i = random.nextInt(2);
//        double v = random.nextDouble();
//        System.out.println(i);
        List<Integer> num = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            num.add(random.nextInt(10));
        }
        //求num里面数字和出现次数
        Map<Integer, Integer> count = new HashMap<>();
        for (int i = 0; i < num.size(); i++) {
            Integer key = num.get(i);

            boolean b = count.containsKey(key);
            Integer v = count.get(key);//隐藏BUG
            if (b) {
                Integer value = count.get(key);
                count.put(key, value + 1);
            } else {
                count.put(key, 1);
            }

        }
        Set<Integer> keySet = count.keySet();
        for (Integer key : keySet) {
            String msg = "数字:" + key + " 出现次数:" + count.get(key);
            System.out.println(msg);

        }

    }

}
